import Vue from 'vue'
import VueRouter from 'vue-router'

import Home from '../views/Home'
import News from '../views/News'
// 宠物中心
import Pet from '../views/Pet'
import PetDetails from '../views/PetDetails'
import PetAdopt from '../views/PetAdopt'

// 产品中心
import Product from '../views/Product'
import ProductDetails from '../views/ProductDetails'

// 用户用心
import Info from '../views/info'



Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: Home,
    meta: {
      isHome: true
    }
  },
  {
    path: '/news',
    name: 'news',
    component: News
  },
  {
    path: '/product',
    name: 'product',
    component: Product
  },
  {
    path: '/product/:id',
    name: 'ProductDetails',
    component: ProductDetails
  },
  {
    path: '/pet',
    name: 'pet',
    component: Pet
  },
  {
    path: '/pet/:id',
    name: 'PetDetails',
    component: PetDetails
  },
  {
    path: '/pet/:id/adopt',
    name: 'PetAdopt',
    component: PetAdopt
  },
  {
    path: '/info',
    name: 'info',
    component: Info,
    children: [
      {
        path: '/info/my',
        name: 'myUser',
        component: () => import('../views/info/myUser')
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/Login'),

    meta: {
      hideNav: true,
      hideFooter: true
    }
  }
]

const router = new VueRouter({
  routes
})


// 路由后置守卫
router.afterEach(() => {
  window.scrollTo(0, 0);
})

export default router
